Skip to content

Port the proc macro attributes to the new attribute parsing infrastructure #143607

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

JonathanBrouwer
Copy link
Contributor

@JonathanBrouwer JonathanBrouwer commented Jul 7, 2025

Ports #[proc_macro], #[proc_macro_attribute], #[proc_macro_derive] and #[rustc_builtin_macro] to the new attribute parsing infrastructure for #131229 (comment)

I've split this PR into commits for reviewability, and left some comments to clarify things
I did 4 related attributes in one PR because they share a lot of their code and logic, and doing them separately is kind of annoying as I need to leave both the old and new parsing in place then.

r? @oli-obk
cc @jdonszelmann

@rustbot rustbot added A-attributes Area: Attributes (`#[…]`, `#![…]`) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jul 7, 2025

// Not a built-in macro
None => (None, helper_attrs),
};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic here should be equivalent to the logic above, other than that this is a bit more readable and that we use the already parsed attribute rather than parsing it from scratch

@@ -57,7 +57,7 @@
// see gated-link-args.rs
// see issue-43106-gating-of-macro_escape.rs for crate-level; but non crate-level is below at "2700"
// (cannot easily test gating of crate-level #[no_std]; but non crate-level is below at "2600")
#![proc_macro_derive()] //~ WARN `#[proc_macro_derive]` only has an effect
#![proc_macro_derive(Test)] //~ WARN `#[proc_macro_derive]` only has an effect
Copy link
Contributor Author

@JonathanBrouwer JonathanBrouwer Jul 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that a breaking change happened here! The code before this change would now produce an error.

Previously a proc_macro_derive applied to the crate could have any arguments it wants, it was not checked. This PR fixes this bug, and this now errors.

I discussed this privately with @jdonszelmann, and she said this is fine to change, though we can consider doing a crater run for this just to make sure if you wish.

@JonathanBrouwer JonathanBrouwer marked this pull request as ready for review July 7, 2025 19:16
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 7, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 7, 2025

Some changes occurred in compiler/rustc_attr_parsing

cc @jdonszelmann

Some changes occurred in compiler/rustc_passes/src/check_attr.rs

cc @jdonszelmann

Some changes occurred in compiler/rustc_attr_data_structures

cc @jdonszelmann

@rust-log-analyzer

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Jul 7, 2025

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

@jdonszelmann
Copy link
Contributor

This could use a little squash I think

@jdonszelmann
Copy link
Contributor

Not everything, but some commits are a bit small

@JonathanBrouwer
Copy link
Contributor Author

JonathanBrouwer commented Jul 8, 2025

@jdonszelmann I've squashed things down a bit. I'm experimenting a bit with what commit size is best for reviewability, this was clearly too much of a good thing :P

@JonathanBrouwer
Copy link
Contributor Author

r? @jdonszelmann
@rustbot ready

@rustbot rustbot assigned jdonszelmann and unassigned oli-obk Jul 8, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 8, 2025

jdonszelmann is not on the review rotation at the moment.
They may take a while to respond.

@bors
Copy link
Collaborator

bors commented Jul 8, 2025

☔ The latest upstream changes (presumably #143645) made this pull request unmergeable. Please resolve the merge conflicts.

@JonathanBrouwer JonathanBrouwer force-pushed the proc_macro_attrs branch 3 times, most recently from 2b42dae to f8c757f Compare July 11, 2025 11:41
@JonathanBrouwer
Copy link
Contributor Author

^ Rebased

@jdonszelmann
Copy link
Contributor

Discussed with @oli-obk, we're going to do a crater run for this one because it's technically a breaking change.
First a try build, no need to rebase until crater's done which will take a bit :)

@bors try

bors added a commit that referenced this pull request Jul 11, 2025
Port the proc macro attributes to the new attribute parsing infrastructure

Ports `#[proc_macro]`, `#[proc_macro_attribute]`, `#[proc_macro_derive]` and `#[rustc_builtin_macro]` to the new attribute parsing infrastructure for #131229 (comment)

I've split this PR into commits for reviewability, and left some comments to clarify things
I did 4 related attributes in one PR because they share a lot of their code and logic, and doing them separately is kind of annoying as I need to leave both the old and new parsing in place then.

r? `@oli-obk`
cc `@jdonszelmann`
@bors
Copy link
Collaborator

bors commented Jul 11, 2025

⌛ Trying commit f8c757f with merge 360f8e6...

@jdonszelmann
Copy link
Contributor

@traviscross what's the proper way to notify T-lang on this? What label, and could you add that?

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Jul 16, 2025
@tmandry
Copy link
Member

tmandry commented Jul 16, 2025

@rfcbot reviewed

1 similar comment
@traviscross
Copy link
Contributor

@rfcbot reviewed

@rfcbot rfcbot added final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. and removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. labels Jul 16, 2025
@rfcbot
Copy link
Collaborator

rfcbot commented Jul 16, 2025

🔔 This is now entering its final comment period, as per the review above. 🔔

@traviscross traviscross added I-lang-radar Items that are on lang's radar and will need eventual work or consideration. and removed I-lang-nominated Nominated for discussion during a lang team meeting. P-lang-drag-1 Lang team prioritization drag level 1. https://rust-lang.zulipchat.com/#narrow/channel/410516-t-lang labels Jul 16, 2025
@bors
Copy link
Collaborator

bors commented Jul 18, 2025

☔ The latest upstream changes (presumably #144109) made this pull request unmergeable. Please resolve the merge conflicts.

@rfcbot rfcbot added finished-final-comment-period The final comment period is finished for this PR / Issue. to-announce Announce this issue on triage meeting and removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels Jul 26, 2025
@rfcbot
Copy link
Collaborator

rfcbot commented Jul 26, 2025

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

This will be merged soon.

@JonathanBrouwer
Copy link
Contributor Author

Perfect, @rust-lang/lang crater seems clear, r=me with your approval

Rebased. As stated above I think @jdonszelmann already reviewed this so I think this is ready to be merged?

@rustbot rustbot added the T-clippy Relevant to the Clippy team. label Jul 26, 2025
@traviscross
Copy link
Contributor

FCP is complete, verified this doesn't need changes in the Reference, and reviewed the differences in the rebase, which look reasonable, so...

@bors r=jdonszelmann,traviscross rollup

@bors
Copy link
Collaborator

bors commented Jul 27, 2025

📌 Commit 97b6521 has been approved by jdonszelmann,traviscross

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. I-lang-radar Items that are on lang's radar and will need eventual work or consideration. needs-fcp This change is insta-stable, or significant enough to need a team FCP to proceed. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-clippy Relevant to the Clippy team. T-lang Relevant to the language team to-announce Announce this issue on triage meeting
Projects
None yet
Development

Successfully merging this pull request may close these issues.